package com.test.p22visitor.staticdispatch;

public class Mozi {

    public void ride(Horse h){
        System.out.println("骑马");
    }

    public void ride(WhiteHorse wh){
        System.out.println("骑白马");
    }

    public void ride(BlackHorse bh){
        System.out.println("骑黑马");
    }

    /**
     * !!!!!!!!
     * !!!!!!!!
     * 重载方法的分派是根据静态类型进行的，这个分派过程在编译时期就完成了
     * !!!!!!!
     * !!!!!!!
     * @param args
     */
    public static void main(String[] args) {
        Horse wh = new WhiteHorse();
        Horse bh = new BlackHorse();
        Mozi mozi = new Mozi();
        mozi.ride(wh);
        mozi.ride(bh);
    }

}
